import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path';
import ViteMonacoPlugin from 'vite-plugin-monaco-editor-esm'

// https://vite.dev/config/
export default defineConfig({
  server: {
    proxy: {
      '/api': {
        target: 'http://localhost:3000/',
        changeOrigin: true,
        rewrite: path => path.replace(/^\/api/, '')
      }
    }
  },
  plugins: [
    vue(),
    ViteMonacoPlugin({}),
  ],
  resolve: {
    alias: {
      '@': path.resolve(__dirname, 'src'),
    },
  },
  // 确保 Vite 使用 tsconfig.json
  esbuild: {
    tsconfigRaw: require('./tsconfig.json'),
  },
})